home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1999 Macromedia, Inc. All rights reserved.
-
- //*************** GLOBALS *****************
-
- var HELP_DOC = HELP_cmdCopySupportFiles;
-
- var COPYALL = true;
- var OVERWRITE = false;
-
- var WAS_COPIED = false;
-
- var MAX_PATH = 50;
-
- var VERSION_FILE = "version.txt";
-
-
- //******************* API **********************
-
- function commandButtons(){
- return new Array(BTN_OK,"cmdOK()",
- BTN_Cancel,"cmdCancel()",
- BTN_Help,"displayHelp()");
- }
-
-
- function cmdOK() {
- copyFiles();
- garbageCollect(true);
- window.close();
- }
-
- function cmdCancel() {
- garbageCollect(true);
- window.close();
- }
-
-
- //Checks that the image directories exist, and all the scripts.
- //
- function needToCopy() {
- return (checkScripts(FILE_scriptsUrl, PREF_scriptsUrl));
- }
-
-
- //***************** LOCAL FUNCTIONS ******************
-
- function checkDirectories(theSrcDirectory, theTgtDirectory) {
- var retVal = false;
- var dirList, source, target, iDir;
-
- source = new File(theSrcDirectory);
- target = new File(theTgtDirectory);
-
- // create the target folder
- if (!target.exists()) {
- retVal = true;
- } else {
- dirList = source.list("*.*", "dirs");
- for (iDir=0; iDir < dirList.length; iDir++) {
- retVal = checkDirectories(source.getAbsolutePath() + FILE_sep + dirList[iDir],
- target.getAbsolutePath() + FILE_sep + dirList[iDir]);
- if (retVal) break;
- } }
- return retVal;
- }
-
-
- function checkScripts(theSrcDirectory, theTgtDirectory) {
- var retVal = false;
- var iFile, iDir, fileList, dirList;
- var source, target, fromFile, toFile;
-
- source = new File(theSrcDirectory);
- target = new File(theTgtDirectory);
-
- // create the target folder
- if (!target.exists()) {
- retVal = true;
- } else {
- fileList = source.list("*.*");
- fromFile = new File("");
- toFile = new File("");
-
- // check the version
- toFile.setPath(target.getAbsolutePath() + FILE_sep + VERSION_FILE);
- fromFile.setPath(source.getAbsolutePath() + FILE_sep + VERSION_FILE);
- if (fromFile.exists()) {
- if (!toFile.exists())
- retVal = true;
- else if (toFile.getContents() != fromFile.getContents())
- retVal = true;
- }
-
- // check the files
- if (!retVal) {
- for (iFile=0; iFile < fileList.length; ++iFile) {
- toFile.setPath(target.getAbsolutePath() + FILE_sep + fileList[iFile]);
- fromFile.setPath(source.getAbsolutePath() + FILE_sep + fileList[iFile]);
- if (!toFile.exists()) {
- retVal = true;
- break;
- } } }
-
- if (retVal) {
- dirList = source.list("*.*", "dirs");
- for (iDir=0; iDir < dirList.length; ++iDir) {
- retVal = checkScripts(source.getAbsolutePath() + FILE_sep + dirList[iDir],
- target.getAbsolutePath() + FILE_sep + dirList[iDir]);
- if (retVal) break;
- } }
- }
- return retVal;
- }
-
- function copyFiles() {
- window.close();
-
- WAS_COPIED = copySupportFiles(false, COPYALL, OVERWRITE);
- }
-
- function initializeUI() {
- if (!regCheck()) {
- window.close();
- return;
- }
-
- var scripts = new File(PREF_scriptsUrl);
- var scriptLabel = findObject("scriptsUrl");
- var scriptsPath = scripts.getAbsolutePath();
- if (scriptsPath.length > MAX_PATH + 3)
- scriptsPath = scriptsPath.substring(0, MAX_PATH/2) + "..." + scriptsPath.substring(Math.max(0, scriptsPath.length - MAX_PATH/2));
- scriptLabel.innerHTML = scriptsPath;
-
- var images = new File(PREF_imagesUrl);
- var imageLabel = findObject("imagesUrl");
- var imagesPath = images.getAbsolutePath();
- if (imagesPath.length > MAX_PATH + 3)
- imagesPath = imagesPath.substring(0, MAX_PATH/2) + "..." + imagesPath.substring(Math.max(0, imagesPath.length - MAX_PATH/2));
- imageLabel.innerHTML = imagesPath;
-
- document.theForm.copyAll.checked = COPYALL;
- document.theForm.overwrite.checked = OVERWRITE;
-
- }
-
-